const LEN = 2560;

cc.Class({
    extends: cc.Component,

    properties: {
        
    },

    onLoad: function () {
        var bg1 = cc.instantiate(this.node.find('game_bg_1'));
        var bg2 = cc.instantiate(this.node.find('game_bg_2'));
        bg1.parent = this.node;
        bg2.parent = this.node;

        this.startX = LEN - GLOBAL.WIN_WIDTH / 2 - 640;
        this.finishX = -GLOBAL.WIN_WIDTH / 2 - 640;
        this.node.x = this.startX;
    },

    onMoveStart() {
        this.moveX = this.node.x;
    },

    updateX(x) {
        this.node.x = this.moveX - x;
        if (this.node.x <= this.finishX) {
            this.node.x = this.startX;
            this.moveX += LEN;
        }
    },
});
